<template>
    <div class="adderss-box">
        <img src="http://img.xianyufanshen.net//goods/image/zanwushouhuodizhi@2x.png" alt="">
        <p  v-if="lang=='zh' "  >您还没有收货地址，快去添加吧~</p>
        <p v-else >You don't have a shipping address yet, go add it~</p>
        <div  v-if="lang=='zh' "  class="btn" @click="addAddress">新增地址</div>
        <div  v-else   class="btn" @click="addAddress">Add address</div>
    </div>
</template>
<script>
export default {
    name:'noAddress',
    data (){
        return{
           lang:'zh',//当前网页语言类型 zh 中文  en 英语  
           userId:0,//用户id 
           id:0,//订单id
           orderType:1,//选择商品类型 1购买 2 置换
        }
    },
    //实例创建完成后被立即调用
    created (){
        //获得语言类型lang
        if(this.$route.query.lang){
            this.lang = this.$route.query.lang;
        }
        //获取用户id
        if(this.$route.query.userId && this.$route.query.userId > 0){
            this.userId = this.$route.query.userId;
             //把用户id存储在缓存
             window.localStorage.setItem("userId",this.userId);
        }else{
            this.userId = window.localStorage.getItem("userId");
        }
         //获取商品id
        if(this.$route.query.id && this.$route.query.id > 0){
            this.id = this.$route.query.id;
        }
        //获取type
        if(this.$route.query.orderType){
            this.orderType = this.$route.query.orderType;//根据type判断是购买还是置换
        }
       
    },
    //
    methods:{
        //跳转到添加地址页面
        addAddress(){
            console.log("添加地址");
            // this.$router.push({path: '/addAddress', query: {id:this.id,type:1,lang:this.lang,userId:this.userId,orderType:this.orderType}});
            let para = {};
            if(this.lang == 'zh'){
                para.title = "新增地址";
            }else{
                para.title = "add address";
            }
            para.url = "/addAddress?type=1&lang="+this.lang+"&userId="+this.userId+"&id="+this.id+"&orderType="+this.orderType;
            this.interaction.hLink(para);
        },
    }
    
}
</script>

<style lang="stylus" scoped>
.adderss-box{
    padding-top :2.933333rem;
    text-align:center;
    img{
        width:3.2rem;
        height:3.2rem;
        margin :0 auto;
    }
    p{
        font-family:PingFangSC-Regular;
        font-size:.346667rem;
        color:#a2a2a2;
        letter-spacing:.0048rem;
        margin-top :.373333rem;
        margin-bottom:.8rem;
    }
    .btn{
        border:2px solid #cb9c57;
        border-radius:100px;
        width:6.426667rem;
        height:.96rem;
        line-height :.96rem;
        font-family:PingFangSC-Medium;
        font-size:.373333rem;
        color:#cb9c57;
        letter-spacing:.005067rem;
        text-align:center;
        margin :0 auto;
    }
}
</style>


